package com.axones.planningpoker.rest;

import org.restlet.Application;
import org.restlet.Restlet;
import org.restlet.routing.Router;

import com.axones.planningpoker.rest.service.AuthenticationResource;
import com.axones.planningpoker.rest.service.ItemResource;
import com.axones.planningpoker.rest.service.PasswordResource;
import com.axones.planningpoker.rest.service.ProjectResource;
import com.axones.planningpoker.rest.service.ProjectUserResource;
import com.axones.planningpoker.rest.service.ProjectsResource;
import com.axones.planningpoker.rest.service.UserResource;

public class MainApplication extends Application {

	/**
	 * Creates a root Restlet that will receive all incoming calls.
	 */
	@Override
	public Restlet createInboundRoot() {
		// Create a router Restlet that routes each call
		Router router = new Router(getContext());

		router.attach("/connect/{email}/{password}",
				AuthenticationResource.class);
		router.attach("/password/{email}",
				PasswordResource.class);

		router.attach("/user", UserResource.class);
		router.attach("/user/{id}", UserResource.class);
		
		router.attach("/projectuser", ProjectUserResource.class);
		router.attach("/projectuser/{projectId}/{userId}", ProjectUserResource.class);

		router.attach("/project", ProjectResource.class);
		router.attach("/project/{id}", ProjectResource.class);
		router.attach("/projects/{id}", ProjectsResource.class);
		
		router.attach("/item", ItemResource.class);
		router.attach("/item/{id}", ItemResource.class);
		
		
		return router;
	}
}
